<?php

namespace App\Model;

/**
 * Class Trading_stream
 * @package App\Model
 * @User wuqin
 * @Date 2018/4/10 0010
 * @Time 17:56
 */
class Trading_stream extends Common
{
    /**
     * @var bool
     */
//    public $timestamps = false;
    /**
     * @var string
     */
    protected $table = "trading_stream";
    /**
     * @var string
     */
    protected $primaryKey = 'trading_stream_id';

    /**
     * 方法 : add_trading_stream
     * @User wuqin
     * @DateTime 2018-04-10 17:56
     * @param $var
     * @return Trading_stream|bool
     */
    public function add_trading_stream($var)
    {
        $this->user_id = $var['user_id'];
        $this->change = $var['change'];
        $this->info = $var['info'];
        $this->type = $var['type'];

        return $this->save() ? $this : false;
    }

    /**
     * 方法 : update_trading_stream
     * @User wuqin
     * @DateTime 2018-04-10 17:56
     * @param $var
     * @return Trading_stream|bool
     */
    public function update_trading_stream($var)
    {
        $this->user_id = $var['user_id'];
        $this->change = $var['change'];
        $this->info = $var['info'];
        $this->type = $var['type'];
        return $this->save() ? $this : false;
    }

    public function user()
    {
        return $this->belongsTo(User::class, "user_id");
    }
}
